package common.db.io;


import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Date;
import java.util.Calendar;
import java.sql.Time;
import java.text.SimpleDateFormat;

/**
 * Created by IntelliJ IDEA.
 * User: Paskal
 * Date: May 8, 2009
 * Time: 8:00:43 PM
 * To change this template use File | Settings | File Templates.
 */
public class Logger
{
	private OutputFile output;

	public Logger(String fileName)
	{
		output = new OutputFile(fileName);
	}

	public OutputFile getOutput()
	{
		return output;
	}

	public void log(String phrase)
	{
		try
		{
			SimpleDateFormat s = new SimpleDateFormat("HH:mm:ss,SSS");
			output.writeLine(s.format(new Date()) + " " + phrase);

		}
		catch (IOException e)
		{
			e.printStackTrace();  
		}

	}

	@Override
	protected void finalize() throws Throwable
	{
		try
		{
			output.writeLine("finalizeee");
			close();		// close open files
		}
		finally
		{
			super.finalize();
		}

	}

	public void close()
	{
		output.close();
	}

}
